<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>精选板块</title>
        <link href="css/text.css" rel="stylesheet" type="text/css" />
        <style type="text/css">
            /* 缩小页面滚动条 */
            body::-webkit-scrollbar {
                width: 5px; /* 纵向滚动条宽度 */
                height: 5px; /* 横向滚动条高度 */
            }
            body::-webkit-scrollbar-thumb {
                background-color: #888; /* 滚动条滑块颜色 */
                border-radius: 4px; /* 滚动条滑块圆角 */
            }
            body::-webkit-scrollbar-thumb:hover {
                background-color: #555; /* 鼠标悬停时滚动条滑块颜色 */
            }
            body::-webkit-scrollbar-track {
                background-color: #f1f1f1; /* 滚动条轨道颜色 */
            }
            /* Firefox 滚动条样式 */
            body {
                scrollbar-width: thin;
                scrollbar-color: #888 #f1f1f1;
            }
            .fixedBox{
                border: 1px solid #696969;
                white-space: nowrap;
                scrollbar-width: thin; /* 适用于 Firefox */
                -ms-overflow-style: none; /* 适用于 IE 和 Edge */
            }
            .fixedBox::-webkit-scrollbar {
                width: 1px; /* 纵向滚动条宽度 */
                height: 1px; /* 横向滚动条高度 */
            }
            .fixedBox::-webkit-scrollbar-thumb {
                background-color: #888; /* 滚动条滑块颜色 */
                border-radius: 4px; /* 滚动条滑块圆角 */
            }
            .fixedBox::-webkit-scrollbar-thumb:hover {
                background-color: #555; /* 鼠标悬停时滚动条滑块颜色 */
            }
            .fixedBox::-webkit-scrollbar-track {
                background-color: #f1f1f1; /* 滚动条轨道颜色 */
            }
            p {margin-top:0px;margin-bottom:5px}
            table{
                width:180px; 
                border-collapse:collapse; 
                text-align:center;				
            }
            td,th{
                border:1px solid #696969;
                color:#E1FFFF;  /* 表头文字颜色 */
            }
            td a:link{
                color:#E1FFFF;  /* 列表文字颜色 */
            }

            .highlight-link {
                color: greenyellow !important; /* 使用!important确保优先级 */
            }

        </style>
    </head>
    <body>
        <div id="towrites" style="position:relative;float:left;">
            <div id="bar" style="margin:-5px"></div>
            <div id="towrite"  class="fixedBox" style="position:relative; float:left;border:none;"></div>
            <div id="towritea" class="fixedBox" style="position:relative; float:left;border:none">
                <div id="towriter" style="position:relative; float:left;"></div>
            </div>
        </div>
        <script type="text/javascript" src="js/json2html.js"></script>
        <script type="text/javascript" src="js/jquery.min.js"></script>
        <script type="text/javascript" src="DatePicker/WdatePicker.js"> </script> 
        <script>
            var brcolor = $(".fixedBox").css("border");
            var bkcolor = $("body").css("backgroundColor");
            var thcolor = "";
            var tdcolor = "";
            var dt = "";
            var tt = "";
            var gt = "";
            var k = "0";
            window.onload = function() {
                var day = new Date();
                gt = day.getTime();
                mymonth = day.getMonth()+1;
                myday = day.getDate();
                if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
                if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
                tt = day.getFullYear() + "-" + mymonth + "-" + myday;
                dt = tt;
                changeStyle();
                getSource();
            }
            $(function() {
                setInterval(function() {
                    if(k == "0"){
                        time_range("9:00","15:15") 
                    }
                },
                6000);
            })
            function time_range(beginTime, endTime) {
                var strb = beginTime.split(":");
                if (strb.length != 2) {
                    return false;
                }
                var stre = endTime.split(":");
                if (stre.length != 2) {
                    return false;
                }
                var b = new Date();
                var e = new Date();
                var n = new Date();
                b.setHours(strb[0]);
                b.setMinutes(strb[1]);
                e.setHours(stre[0]);
                e.setMinutes(stre[1]);
                if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
                    getSource();
                    console.log(true)
                    return true;
                } else {
                    console.log(false)
                    return false;
                }
            }
            function changeStyle() {
                var obj = document.getElementById("towrites");
                //obj.style.border="1px solid #fff";
                obj.style.left= "0px";
                obj.style.width= "700%";
                obj.style.height= "600px";
                obj.style.fontSize="12px";
                var obj1 = document.getElementById("towrite");
                obj1.style.border="1px solid #696969";
                obj1.style.left= "0px";
                obj1.style.width= "1.5%";
                obj1.style.height= "83%";
                var obj2 = document.getElementById("towritea");
                obj2.style.border="1px solid #696969";
                obj2.style.left= "0px";
                obj2.style.width= "75%";
                obj2.style.height= "83%";
                var obj3 = document.getElementById("towriter");
                obj3.style.border= "none";
                obj3.style.left= "0px"; 
                obj3.style.width= "320%";
                obj3.style.height= "110%";
            }
            function keepTwoDecimal(num) {  
                var result = parseFloat(num);  
                if (isNaN(result)) {  
                    //alert('传递参数错误，请检查！');  
                    return false;  
                }  
                result = Math.round(num * 100) / 100;  
                return result;  
            };
            Date.prototype.Format = function (fmt) {
                var o = {
                    "M+": this.getMonth() + 1, //月份
                    "d+": this.getDate(), //日
                    "h+": this.getHours(), //小时
                    "m+": this.getMinutes(), //分
                    "s+": this.getSeconds(), //秒
                    "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                    "S": this.getMilliseconds() //毫秒
                };
                if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
                for (var k in o)
                    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                return fmt;
            };
            function cDayFunc(dp) { 
                var date = dp.cal.getNewDateStr();            
                BookingRmk(date);//调用其它函数并带上参数                
            }
            function UnUnicode(str) {
                return unescape(str.replace(/\\/g, "%"));
            }
            window.onresize = function() {
                // var h =  document.getElementById('towrite').offsetHeight ;				 
                // var div = document.getElementById('towritea'); 
                // div.style.height = h - 20 + 'px';	 
            }
            function BookingRmk(date){         
                tt = date;
                var date1 = new Date(tt);
                var date2 = new Date(dt);
                k = 0;
                if(date1.getTime() < date2.getTime()){
                    k = 1;
                    tradeday();
                }
                getSource();
            }
            function prev(){  //前一天
                pn = -1;
                var day = new Date(tt);
                day.setTime(day.getTime() - 24*60*60*1000);
                tt = day.Format("yyyy-MM-dd");
                BookingRmk(tt);
            }
            function next(){  //后一天 				
                pn = 1;
                var day = new Date(tt);
                day.setTime(day.getTime() + 24*60*60*1000);
                tt = day.Format("yyyy-MM-dd");
                BookingRmk(tt);
            }
            var pn = -1;
            function tradeday() {  //判断最后交易日
                var day = new Date(tt);
                for (i = 1; i < 100; i++){	//节假日
                    if(i > 1){
                        day.setTime(day.getTime() + pn*24*60*60*1000);
                    }
                    tt = day.Format("yyyy-MM-dd");
                    //alert(tt);
                    if(tt == dt){	
                        k = 0;
                        getSource();
                        break;
                    }
                    //var url = "http://127.0.0.1:8881/w1/api/index.php?Order=1&a=RealRankingInfo&st=60&apiv=w26&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&Date=" + tt; 			
                    var url = "https://apphis.longhuvip.com/w1/api/index.php?a=RealRankingInfo&apiv=w33&c=ZhiShuRanking&ZSType=5&st=50&Type=1&Order=1&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-63da-215a-a6f3-00000003a92d&Date=" + tt; 		
                    var res = [];
                    $.ajax({
                        type: "get",
                        url: url,
                        dataType: "json",
                        async : false,
                        cache:false,
                        timeout:3000,
                        success: function(data) {
                            res = data.list;
                        }
                    });
                    if(res.length != 0){
                        break;
                    }
                }
            }
            function getSource() {
                var diva = document.getElementById("bar");
                var sx = "<a style='left:30px; color:#00FF00' href='javascript:void(0)' onclick='getSource()'>" + "刷新" + "</a>";
                diva.innerHTML = '<font size="3">' + sx + '</font>';
                var div = document.getElementById('towrite');
                div.innerHTML = '<font size="2" style=color:#FFFF00;>精选板块</font><input style="width:90px;" type="text" id="PriceDate" name="PriceDate" class="Wdate" onFocus="WdatePicker({ onpicking: cDayFunc})" />';
                var back = '<a href="javascript:prev();"  style="padding-left:2px;font-size:16px;color:#fff;">←</a>';
                var forward = '<a href="javascript:next();"  style="font-size:16px;color:#fff;">→</a>';
                div.innerHTML += back + forward ;
                //var url1 = "http://127.0.0.1:8880/w1/api/index.php?Order=1&a=RealRankingInfo&st=60&apiv=w21&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7"; 
                //var url2 = "http://127.0.0.1:8881/w1/api/index.php?Order=1&a=RealRankingInfo&st=60&apiv=w26&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&Date=" + tt; 			
                var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=60&apiv=w21&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&"; 
                var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=60&apiv=w26&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&Date=" + tt;
                var url = url1;
                if(k == "1"){
                    url = url2;
                }

                //...省略...
                var dd = [];	
                var res = [];
                $.ajax({
                    type: "get",
                    url: url,
                    dataType: "json",
                    async : false,
                    cache:false,
                    timeout:3000,
                    success: function(data) { 
                        if(k == 0){
                            tt = data.Day;
                            dt = tt;
                        } 
                        var n = 0;
                        for (i = 0; i < data.list.length; i++){
                            var code = data.list[i][0];
                            var name = data.list[i][1];
                            if(name.indexOf("ST") == -1){
                                n++;
                                if(n ==29){
                                    break;
                                }
                                res.push({"code":data.list[i][0],"name":data.list[i][1],"qd":data.list[i][2],"zf":data.list[i][3],"zs":data.list[i][4]}); 
                                // dd.push({code,name});
                            }
                        }
                        //要求：对 res 进行重新排序，根据  "zs" 的大小 进行降序排序 
                        //在这个位置加，排序代码：

                         // 排序代码
                        res.sort((a, b) => b.zs - a.zs);  // 根据zs属性降序排序
                        dd = res.map(({ code, name }) => ({ code, name }));

                    }

                    //...省略....
                });
                //document.write(JSON.stringify(dd));
                //var json = JSON.parse(bks);	
                var json = res;	
                //创建table
                var table = document.createElement("table");
                var thead = document.createElement("thead");
                table.appendChild(thead);
                var tr = document.createElement("tr");
                thead.appendChild(tr);
                for(var key in json[0]){  //表头
                    key = key.replace('code','代码').replace('name','名称').replace('qd','强度').replace('zf','涨幅%').replace('zs','涨速');
                    var th = document.createElement("th");
                    th.innerHTML = key;
                    tr.appendChild(th);
                }
                var tbody=document.createElement("tbody");
                table.appendChild(tbody);
                //遍历json
                for(var i = 0; i < json.length; i++){
                    var tr = document.createElement("tr");
                    var p = 1						
                    for(var key in json[i]){ //行元素遍历
                        var td = document.createElement("td");
                        var rc = json[i][key];
                        if(p == 1){  //代码列
                            dm = rc;
                        }
                        if(p == 4){
                            rc = keepTwoDecimal(rc);
                        }
                        //td.innerHTML = rc
                        td.innerHTML = "<a href='javascript:void(0)' id='" + p + "' onclick='changeCss(\"towrite" + dm + "\");Focus(\"towrite" + (i + 1) + "\")'>" + rc + "</a>";
                        tr.appendChild(td);
                        tr.id = "towrite" + dm;
                        p++;
                    }
                    $("table tr").find("td:eq(0)")
                    tbody.appendChild(tr);
                }
                div.appendChild(table);
                //table.id = id;				
                changeTable(table,"0");		//隐藏某列					
                AddTableCell(table);   //添加序号列
                makeSortable(table); //排序
                hovera();
                //延迟显示板块个股
                setTimeout(loop, 100);
                var m = 0;
                function loop(){
                    var code = dd[m]["code"];
                    var name = dd[m]["name"];
                    m++;
                    bkgg(m,code,name);
                    if( m < dd.length){
                        setTimeout(loop, 100);
                    }
                };
                document.getElementById("PriceDate").value = tt;
                //初始化高亮
                $("#towritea").scrollLeft (0);
                var tlist = document.getElementById("towriter").getElementsByTagName('div');
                for(var i = 0; i < tlist.length; i++){
                    tlist[i].style.border = brcolor;
                }	
            }
            //动态添加列
            function AddTableCell(table){
                var Table = table			   
                var rowLength = Table.rows.length;  //行數量
                //var cellLength=Table.rows[0].cells.length; //查找單元格数量
                for(var i = 0; i < rowLength; i++){
                    var NewCell = Table.rows[i].insertCell(0);
                    if(i == 0){
                        NewCell.innerHTML = "序号";
                    }else{
                        NewCell.innerHTML = i;
                    }
                }				
            }
            function Focus(id){  //移动
                //alert(brcolor)				
                var tlist = document.getElementById("towriter").getElementsByTagName('div');
                for(var i = 0; i < tlist.length; i++){
                    tlist[i].style.border = brcolor;
                }	
                var div = document.getElementById(id);				
                div.style.border = "3px solid #FFA500";
                var x = div.offsetLeft;
                $("#towritea").scrollLeft (x);				
            }

            
            var rid = "";
            function changeCss(id){	
                rid = id;
                var tlist = document.getElementById("towrite").getElementsByTagName('tr');
                for(var i = 0; i < tlist.length; i++){
                    tlist[i].style.backgroundColor = bkcolor;
                }				
                var tr = document.getElementById(id);				
                tr.style.backgroundColor = "#3366FF";						
            }

            function hovera(){  //鼠标经过
                //var rows = document.getElementsByTagName('tr');
                var rows = document.getElementById("towrite").getElementsByTagName('tr');
                for(var i=0;i<rows.length;i++){
                    rows[i].onmouseover=function(){
                        if(this.id != ""){  //过滤表头
                            this.style.background="#990033";
                        }
                    }
                    rows[i].onmouseout=function(){
                        if(this.id != ""){  //过滤表头
                            if(rid == this.id){
                                this.style.background ="#3366FF";
                            }else{
                                this.style.background = bkcolor;
                            }
                        }
                    }
                }
            } 




            function bkgg(n,code,name){	
                var newDiv = document.getElementById("towrite" + n);
                if(!newDiv){
                    //添加分类Div				
                    var newDiv = document.createElement("div");
                    newDiv.id = "towrite" + n;
                    newDiv.className = "fixedBox";
                    newDiv.style.left = "0px"; 	
                    newDiv.style.width = "330px";
                    newDiv.style.position = "relative"; 
                    newDiv.style.float = "left";
                    newDiv.style.fontSize="12px";
                    newDiv.style.whiteSpace = "nowrap";	
                    document.getElementById("towriter").appendChild(newDiv);
                }				
                newDiv.innerHTML = "<font size='2' style=color:#FFFF00;>" + name + "</font>";
                var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&st=60&a=ZhiShuStockList_W8&c=ZhiShuRanking&PhoneOSNew=1&old=1&apiv=w21&Type=6&DeviceID=6575961a-b25b-3831-aa2b-4a373b51b256&VerSion=5.12.0.0&PlateID=" + code;							
                var url2 = "https://apphis.longhuvip.com/w1/api/index.php?st=60&Index=0&old=1&Order=1&a=ZhiShuStockList_W8&apiv=w26&Type=6&c=ZhiShuRanking&PhoneOSNew=1&DeviceID=6575961a-b25b-3831-aa2b-4a373b51b256&VerSion=5.12.0.0&PlateID=" + code + "&Date=" + tt;		
                //var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=" + order + "&st=60&a=ZhiShuStockList_W8&c=ZhiShuRanking&PhoneOSNew=1&old=" + old + "&apiv=w21&Type=" + type + "&DeviceID=6575961a-b25b-3831-aa2b-4a373b51b256&VerSion=5.12.0.0&PlateID=" + bdm; 								
                //var url2 = "https://apphis.longhuvip.com/w1/api/index.php?st=60&Index=0&old=" + old + "&Order=" + order + "&a=ZhiShuStockList_W8&apiv=w26&Type=" + type + "&c=ZhiShuRanking&PhoneOSNew=1&DeviceID=6575961a-b25b-3831-aa2b-4a373b51b256&VerSion=5.12.0.0&PlateID=" + bdm + "&Date=" + tt;		
                var url = url1;
                if(k == "1"){
                    url = url2;
                }	
                var res = [];
                var num = 0; //涨停数
				var zbNum = 0;
				var totalNum = 0;
				var lbzgNum=0;
				var lbzgName='';	
				var lbzgCode='';
				var zgNum=0;	 
				var zgName='';	
				var zgBNum='';
				var zgCode='';
                $.ajax({
                    type: "get",
                    url: url,
                    dataType: "json",
                    async : false,
                    cache:false,
                    timeout:3000,
                    success: function(data) {
                        for (i = 0; i < data.list.length; i++){
							var aa = data.list[i];
							var code = aa[0].trim();
							//if(code.substr(0,1)=="3"){
								//代码 ，名字，涨幅，连扳，板块，封单, 是否炸板，最高板数

								// 获取原始字符串
								var originalString = aa[23].trim();
								
								// 使用正则表达式匹配开头的数字
								var regex = /^\d+/; 
								
								// 提取的数字，如果存在的话 ， N 连扳
								var lianban = /^[0-9]{1,}连板$/.test(originalString.toString());
								if(lianban){
									var match = originalString.match(regex);
									var extractedNumber = match ? match[0] : '';
									var nn = parseInt(extractedNumber);
									if(nn> 0){
									if(lbzgNum<nn){
										lbzgNum=extractedNumber;
										lbzgName=aa[1].trim();
										lbzgCode=code;
										}
									}
								}

								// 提取的数字，如果存在的话 ，N 天N 扳
								var match = originalString.match(regex);
								var extractedNumber = match ? match[0] : '';
								var nn = parseInt(extractedNumber);
								if(nn> 0){
								if(zgNum<nn){
									zgNum=extractedNumber;
									zgName=aa[1].trim();
									zgCode=code;
									zgBNum=originalString.replace('天',',').replace('板','')
									} 
								}    

								res.push({"code":code,"name":aa[1].trim(),"zf":aa[6],"lb":aa[23],"bk":aa[4].substr(0,11),"fd":aa[28],"zb":aa[24].toString().trim(),"zg":extractedNumber});
								if(aa[28]>0){
									num ++;  //涨停数
								} 

								if(aa[24].toString().trim()=="破板"){
									zbNum ++;
								}
							//}							
						}		
                    }
                });
                //document.write(data);
                //var json = JSON.parse(data);
                var json = res;	
                //创建table					
                var table=document.createElement("table");
                var thead=document.createElement("thead");
                table.appendChild(thead);
                var tr=document.createElement("tr");
                thead.appendChild(tr);
                var m = 0;
                var v = 0;
                var b = 0;
                var gl = "涨幅";  //高亮
                for(var key in json[0]){  //表头
                    key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('lb','连板').replace('bk','板块');
                    var th=document.createElement("th");
                    th.innerHTML=key;
                    tr.appendChild(th);
                    if(key == "连板"){
                        b = m;
                        th.style.color = "#FFA500";
                    }
                    if(gl == key.replace("%","")){
                        v = m;
                        th.style.color = "#FF6633";	
                    }
                    m++;
                }
                var tbody=document.createElement("tbody");
                table.appendChild(tbody);
                //遍历json
                for(var i = 0; i < json.length; i++){
                    var tr=document.createElement("tr");
                    var p = 1;	
                    var dm = "";
                    var mc = "";
                    for(var key in json[i]){ //行元素遍历
                        var td=document.createElement("td");
                        var rc = json[i][key];
                        if(p == 1){  //代码列
                            dm = rc;
                            tr.id = dm + "##" + code;
                        }


                        if(key=="lb"){
							var zb = json[i]["zb"];
							if (zb=="破板"){
								rc = zb;  
							} 
						}


                        td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='changeTCss(\"" + newDiv.id + "\",\"" + tr.id + "\")'>" + rc + "</a>";
                        


                        if(key=="lb"){
							var zb = json[i]["zb"];
							if (zb=="破板"){  
								td.getElementsByTagName("a")[0].classList.add("highlight-link");
							} 
						}

                        // 300 688 689 301 变色
						if(dm.substr(0,2)=="30" || dm.substr(0,2)=="68"){
							tr.style.backgroundColor  = "#2F4F4F"; 
						}	 


                        if(p == b + 1){
                            td.getElementsByTagName("a")[0].style.color = "#FFA500";
                        }
                        if(p == v + 1){
                            td.getElementsByTagName("a")[0].style.color = "#FF6633";
                        } 
                        
                        tr.appendChild(td);
                        p++;
                    }

                    tbody.appendChild(tr);
                }
                newDiv.appendChild(table);
                table.id = code;
                changeTable(table,"0#5#6#7");		//隐藏某列	
                makeSortable(table);			
                hover();				
            }
            //隐藏某列				
            function changeTable(table,ss) {	
                var trs = table.rows;
                ss = ss + '#';
                var aa = ss.split('#');
                for (var j = 0; j < aa.length; j++) {
                    if(aa[j] != ""){
                        for (var i = 0, len = trs.length; i < len; i++) {					
                            var p = aa[j];
                            var cell = trs[i].cells[p]; 
                            cell.style.display = 'none';
                        }
                    }
                }					
            }
            var trid = "";
            function changeTCss(tid,id){				
                trid = id;
                var dm = id.split("##")[0];
                var bk = id.split("##")[1];
                var tlist = document.getElementById("towriter").getElementsByTagName("tr");
                for(var i = 0; i < tlist.length; i++){
                    var dms = tlist[i].id.split("##")[0];
                    var bks = tlist[i].id.split("##")[1];
                    if(dms == dm){
                        tlist[i].style.backgroundColor = "#3366FF";
                        if(bks != bk){
                            var t = tlist[i].parentNode.parentNode.parentNode.id;  //td父节点tr id
                            $("#" + t).scrollTop (0);
                            var y = getTop(tlist[i]);  //纵坐标
                            var div = document.getElementById(t);
                            if(y > div.clientHeight){
                                $("#" + t).scrollTop (y - 100);  //控制滚动条
                            }
                        }
                    }else{
                        if(dms.substr(0,1)=="3"){
                            tlist[i].style.backgroundColor = gcolor;
                        }else{
                            tlist[i].style.backgroundColor = bkcolor;
                        }	
                        //tlist[i].style.backgroundColor = bkcolor;
                    }
                }
                //var tr = document.getElementById(id);				
                //tr.style.backgroundColor = "#3366FF";						
            }
            //获取元素的纵坐标 
            function getTop(e){ 
                var offset=e.offsetTop; 
                if(e.offsetParent!=null) offset+=getTop(e.offsetParent);				
                return offset; 
            } 		
            var gcolor = "#8B1A1A";   // 定义创业板股票的背景色为深紫色    //#8B008B
            function hover(){  //鼠标经过
                var rows = document.getElementById("towriter").getElementsByTagName('tr');
                for(var i=0;i<rows.length;i++){
                    rows[i].onmouseover=function(){
                        if(this.id != ""){  //过滤表头
                            this.style.background="#2F4F3F";  // 鼠标悬停时的颜色（深紫红色）
                        }
                    }
                    rows[i].onmouseout=function(){
                        if(this.id != ""){  //过滤表头
                            if(trid == this.id){
                                this.style.background ="#3366FF";  // 选中状态的颜色（蓝色）
                            }else{
                                if(this.id.substr(0,1)=="3"){
                                    this.style.backgroundColor = gcolor;
                                }else{
                                    this.style.backgroundColor = bkcolor;
                                }	
                                //this.style.background = bkcolor;
                            }
                        }
                    }
                }
            }
            function makeSortable(table) {		
                var headers=table.getElementsByTagName("th");
                for(var i=0;i<headers.length;i++){				
                    (function(n){
                        var flag=false;
                        headers[n].onclick=function(){
                            showCol(table,n);		//高亮
                            var tbody=table.tBodies[0];
                            var rows=tbody.getElementsByTagName("tr");
                            rows=Array.prototype.slice.call(rows,0);
                            //基于第n个<td>元素的值对行排序
                            rows.sort(function(row1,row2){
                                headtxt = headers[n].textContent;
                                var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
                                var cell2=row2.getElementsByTagName("td")[n];
                                var val1=cell1.textContent||cell1.innerText;//获得文本内容
                                var val2=cell2.textContent||cell2.innerText;
                                if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("主力") != -1|| headtxt.indexOf("主题") != -1){
                                    val1 = val1;
                                    val2 = val2;
                                }else if(headtxt.indexOf("连板") != -1){
                                    val1 = val1.replace("昨日首板","-1").replace("首板","1").replace("连板","");
                                    if(val1.indexOf("天")>-1){
                                        val1 = val1.split("天")[0];
                                    }else if(val1.indexOf("昨")>-1){
                                        val1 = 0;
                                    }else if(val1 == ""){
                                        val1 = -2;
                                    }
                                    val1 = parseFloat(val1);
                                    val2 = val2.replace("昨日首板","-1").replace("首板","1").replace("连板","");
                                    if(val2.indexOf("天")>-1){
                                        val2 = val2.split("天")[0];
                                    }else if(val2.indexOf("昨")>-1){
                                        val2 = 0;
                                    }else if(val2 == ""){
                                        val2 = -2;
                                    }
                                    val2 = parseFloat(val2);
                                }else{
                                    if(val1.indexOf("万") != -1){
                                        val1 = parseFloat(val1)*10000;
                                    }else if(val1.indexOf("亿") != -1){
                                        val1 = parseFloat(val1)*100000000;
                                    }else{
                                        val1 = parseFloat(val1);
                                    }
                                    if(val2.indexOf("万") != -1){
                                        val2 = parseFloat(val2)*10000;
                                    }else if(val2.indexOf("亿") != -1){
                                        val2 = parseFloat(val2)*100000000;
                                    }else{
                                        val2 = parseFloat(val2);
                                    }
                                }
                                if(val1<val2){
                                    return -1;
                                }else if(val1>val2){
                                    return 1;
                                }else{
                                    return 0;
                                }
                            });
                            if(flag){
                                rows.reverse();
                            }
                            for(var i=0;i<rows.length;i++){
                                tbody.appendChild(rows[i]);
                            }
                            flag=!flag;
                        }
                    }(i));
                }
            }
            function showCol(table,iCol){			
                var oTable = table;
                var id = oTable.id;
                for (i=0;i < oTable.rows.length; i++){
                    for (j=0;j < oTable.rows[0].cells.length; j++){
                        //alert(oTable.rows[i].cells[3].innerText)
                        oTable.rows[i].cells[j].style.color = thcolor;
                        //if(oTable.id != "towrite6"){
                            oTable.rows[i].cells[3].style.color = "#FFA500";
                        //}						
                    }
                    oTable.rows[i].cells[iCol].style.color = "#FF6633";					
                }
                var otagsA = oTable.getElementsByTagName("a");  //a变色
                for (i = 0; i < otagsA.length; i++) {
                    otagsA[i].style.color = tdcolor;
                    if(otagsA[i].id == 4){
                        otagsA[i].style.color = "#FFA500";
                    }	
                    if(otagsA[i].id == iCol + 1){
                        otagsA[i].style.color = "#FF6633";
                    }
                }				
            }
        </script>
    </body>
</html>
    